/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.cescorp.aplicacion.dao.impl;

import com.cescorp.aplicacion.dao.PeliculaDao;
import com.cescorp.aplicacion.entidades.Pelicula;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 *
 * @author C588
 */
@Repository
public class PeliculaDaoImpl implements PeliculaDao{
    
    @Autowired
    private SessionFactory sessionFactory;

    @Override
    public void add(Pelicula pelicula) {
        sessionFactory.getCurrentSession().save(pelicula);
    }

    @Override
    public void update(Pelicula pelicula) {
        sessionFactory.getCurrentSession().update(pelicula);
    }

    @Override
    public void delete(int id) {
        sessionFactory.getCurrentSession().delete(id);
    }

    @Override
    public List getAll() {
        return sessionFactory.getCurrentSession().createQuery("from pelicula").list();
    }

    @Override
    public Pelicula get(int id) {
        return (Pelicula) sessionFactory.getCurrentSession().get(Pelicula.class, id);
    }
    
}
